#ifndef __APP_HPP__
#define __APP_HPP__

#include "SDL.h"
#include "macro.hpp"
#include "sdl_view.hpp"
#include "res_loader.hpp"
#include "scheduler.hpp"
#include "input_manager.hpp"
#include <memory>
#include <vector>

class Node;
class Component;

mb NodeZIdexSort( Component* const& n1, Component* const& n2 );

class App
{
private:
    mb __gameOver;
    Uint32 __timePass; //
    Uint32 __fps; //
    Uint32 __realRunTime; //
    Uint32 __minFreshTime; //
public:
    mb showDebug = 1;
    SDLView* view;
    Node* root;
    InputManager* inputManager;
    Scheduler* scheduler;
    ResLoader* resLoader;

    App();
    ~App();

    void init( std::string const& gameName = "app", unsigned int screenWidth = 640, unsigned int screenHeight = 480, unsigned int designWidth = 640, unsigned int designHeight = 480, std::string const& fontName = "ARIAL.TTF", Uint32 windowFlags = SDL_WINDOW_SHOWN );
    void exit();

    void run();
    void closingEveryThing();
    void update( float dt );//
    void visit();//

    void batchDraw();//

    void drawCom( Component* com );
    std::vector<Component*> drawList;
};

#endif //__APP_HPP__